/*
 * @Author: wuqingchun
 * @Date: 2024-07-29 16:54:53
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-07-31 16:40:53
 */
#ifndef __EV_LOG_H__
#define __EV_LOG_H__

#define LOG_LEVEL_DEBUG     0
#define LOG_LEVEL_INFO      1
#define LOG_LEVEL_WARN      2
#define LOG_LEVEL_ERROR     3

/**
  A callback function used to intercept Libevent's log messages.

  @see event_set_log_callback
 */
typedef void (*EV_LOG_CB_PF)(int severity, const char *msg);

/**
 * @brief 设置日志回调函数，用于截获 libevent的内部日志信息
 * 
 * @param pfCB 
 */
void EV_log_SetCB(EV_LOG_CB_PF pfCB);
void EV_log_Output(int iLogLevel, const char *pcFmt, ...);

#define LOG_DEBUG(fmt, ...)\
    EV_log_Output(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)

#define LOG_INFO(fmt, ...)\
    EV_log_Output(LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)

#define LOG_WARN(fmt, ...)\
    EV_log_Output(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
    
#define LOG_ERROR(fmt, ...)\
    EV_log_Output(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)

#endif //__EV_LOG_H__